//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System.ComponentModel;
using System.Workflow.ComponentModel;
using Microsoft.Research.ScientificWorkflow;

namespace TridentBasicActivities.Activities
{
    [Name("Activity for inverting a boolean value", "Condition NOT", "NOT")]
    [Description("Inverts the input value.")]
    [WorkflowCategory("Condition")]
    public class CondNOT : CondBase
    {
        public static System.Workflow.ComponentModel.DependencyProperty InputProperty =
            System.Workflow.ComponentModel.DependencyProperty.Register("Input", typeof(bool),
            typeof(CondNOT));

        [RequiredInputParam]
        [Name("Input Boolean")]
        [Description("Boolean input to be inverted.")]
        public bool Input
        {
            get { return (bool)GetValue(CondNOT.InputProperty); }
            set { SetValue(CondNOT.InputProperty, value); }
        }

        public static readonly System.Workflow.ComponentModel.DependencyProperty ResultProperty =
            System.Workflow.ComponentModel.DependencyProperty.Register("Result", typeof(bool),
            typeof(CondNOT));

        [OutputParam]
        [Name("Result")]
        [Description("Result of the NOT operation.")]
        public bool Result
        {
            get { return (bool)GetValue(CondNOT.ResultProperty); }
            set { SetValue(CondNOT.ResultProperty, value); }
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.Result = !this.Input;
            return ActivityExecutionStatus.Closed;
        }

        public CondNOT()
        {
        }
    }
}
